﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
public partial class Main_Reports_Inventory_PurchaseOrder_Local : System.Web.UI.Page
{
    Datautility DU = new Datautility();
    DataTable DT = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GetData()
    {
        if (txtfromdate.Text != "" && txttodate.Text != "")
        {
            lblperiod.Text = "Period :" + txtfromdate.Text + " to " + txttodate.Text;
            SqlParameter[] ParamPOImport = { 
                                               new SqlParameter("@fromdate",Convert.ToDateTime(txtfromdate.Text).ToString(string.Format("yyyy/MM/dd"))),
                                            new SqlParameter("@todate",Convert.ToDateTime(txttodate.Text).ToString(string.Format("yyyy/MM/dd")))
                                           };
            DT = DU.getdatausingprocedure("IVR_RPT_PURCHASELOCAL_REPORT", ParamPOImport);
            if (DT.Rows.Count > 0)
            {
                GrdPurchaseLocal.DataSource = DT;
                GrdPurchaseLocal.DataBind();
            }
        }
    }
    protected void btngetreport_Click(object sender, EventArgs e)
    {
        GetData();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {

    }
    public override void VerifyRenderingInServerForm(Control control)
    {
        //base.VerifyRenderingInServerForm(control);
    }
    protected void ImgBtnExcel_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "PurchaseLocal_Report.xls"));
            Response.ContentType = "application/ms-excel";
            GrdPurchaseLocal.ShowFooter = false;
            GrdPurchaseLocal.AllowPaging = false;
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            Response.Write(sw.ToString());
            GrdPurchaseLocal.RenderControl(htw);
            Response.End();
        }
        catch (Exception ex)
        {
        }
    }
}